<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>MediaWiki Code Example</title>
	<script>
		/**
		 * Basic log console for the example iframe in documentation pages.
		 */
		var log = ( function () {
			var pre;
			return function () {
				var str, i, len, line;
				if ( !pre ) {
					pre = document.createElement( 'pre' );
					pre.className = 'mw-jsduck-log';
					( document.body || document.documentElement ).appendChild( pre );
				}
				str = [];
				for ( i = 0, len = arguments.length; i < len; i++ ) {
					str.push( String( arguments[ i ] ) );
				}
				line = document.createElement( 'div' );
				line.className = 'mw-jsduck-log-line';
				line.appendChild(
						document.createTextNode( str.join( ' , ' ) + '\n' )
				);
				pre.appendChild( line );
			};
		}() );

		window.onerror = function ( error, filePath, linerNr ) {
			log( error + '\n' + filePath + ':' + linerNr  );
		};
	</script>
	<script>
		// Mock StartUpModule substitutions
		window.$VARS = {
			baseModules: [],
			storeEnabled: false,
			maxQueryLength: 2000
		};
		window.$CODE = {
			test: function () { return true; },
			maybeRedefineFallbacksForTest: function () {}
		};
		// Mock startup.js
		window.RLQ = [];
		// Mock mw.loader#execute context
		function require() {}
	</script>
	<script src="modules/src/startup/mediawiki.js"></script>
	<script src="modules/src/startup/mediawiki.loader.js"></script>
	<script src="modules/src/startup/mediawiki.requestIdleCallback.js"></script>
	<script src="modules/lib/jquery/jquery.js"></script>
	<script src="modules/src/mediawiki.base/log.js"></script>
	<script src="modules/src/mediawiki.base/errorLogger.js"></script>
	<script src="modules/src/mediawiki.base/mediawiki.base.js"></script>
	<script src="modules/lib/oojs/oojs.js"></script>
	<script src="modules/lib/ooui/oojs-ui-core.js"></script>
	<script src="modules/lib/ooui/oojs-ui-widgets.js"></script>
	<script src="modules/lib/ooui/oojs-ui-toolbars.js"></script>
	<script src="modules/lib/ooui/oojs-ui-windows.js"></script>
	<script src="modules/lib/ooui/oojs-ui-wikimediaui.js"></script>
	<style>
		body {
			font-size: 0.8em;
			font-family: sans-serif;
		}

		.mw-jsduck-log {
			position: relative;
			min-height: 3em;
			margin-top: 2em;
			background: #f7f7f7;
			border: 1px solid #e4e4e4;
		}

		.mw-jsduck-log::after {
			position: absolute;
			bottom: 100%;
			right: -1px;
			padding: 0.5em;
			background: #fff;
			border: 1px solid #e4e4e4;
			border-bottom: 0;
			border-radius: 0.5em 0.5em 0 0;
			font: normal 0.5em sans-serif;
			content: 'console';
		}

		.mw-jsduck-log-line {
			padding: 0.2em 0.5em;
			white-space: pre-wrap;
		}

		.mw-jsduck-log-line:nth-child(odd) {
			background: #fff;
		}
	</style>
	<link rel="stylesheet" href="modules/lib/ooui/oojs-ui-core-wikimediaui.css">
	<link rel="stylesheet" href="modules/lib/ooui/oojs-ui-widgets-wikimediaui.css">
	<link rel="stylesheet" href="modules/lib/ooui/oojs-ui-toolbars-wikimediaui.css">
	<link rel="stylesheet" href="modules/lib/ooui/oojs-ui-windows-wikimediaui.css">
	<link rel="stylesheet" href="modules/lib/ooui/oojs-ui-images-wikimediaui.css">
</head>
<body>
<script>
	if ( window.mw ) {
		mw.log = log;
	}

	/**
	 * Method called by jsduck to execute the example code.
	 */
	function loadInlineExample( code, options, callback ) {
		try {
			eval( code );
			callback && callback( true );
		} catch ( e ) {
			log( 'Uncaught ' + e );
			callback && callback( false, e );
			throw e;
		}
	}
</script>
</body>
</html>
